Skip to content

feat(stellar): Structure failed tx status_reason#765

Merged
dylankilkenny merged 1 commit into
mainfrom
001-stellar-failure-detail
May 7, 2026
Merged

feat(stellar): Structure failed tx status_reason#765
dylankilkenny merged 1 commit into
mainfrom
001-stellar-failure-detail

Conversation

@dylankilkenny
Copy link
Copy Markdown
Member

@dylankilkenny dylankilkenny commented May 6, 2026

Summary

The status_reason written for failed Stellar transactions today is a single free-form sentence:

Transaction failed on-chain. Provider status: FAILED. Specific XDR reason: TxFeeBumpInnerFailed.

This PR replaces it with a structured, layered key=value form that includes those, and adds a matching contract_error field to the stellar transaction failed warn log line.

Transaction failed on-chain. reason=TxFeeBumpInnerFailed inner=TxFailed op=Trapped contract_error=Contract(8) message="failing with contract error"

Components are emitted only when their source data is available, so non-Soroban / classic failures stay clean (no op=unknown placeholders, no spurious contract_error=).

Compatibility

⚠️ status_reason is free-form text but its wording has changed. Anything downstream that parses or grep-matches the prior sentence ("Provider status: FAILED. Specific XDR reason: <code>.") will need updating. Keys (reason=, inner=, op=, contract_error=, message="...") are stable going forward.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling for failed Stellar transactions with more detailed diagnostic information and clearer error messages.
    • Improved extraction and reporting of contract-level errors during transaction failures.
  • Tests

    • Expanded test coverage for transaction failure scenarios and error reporting logic.

Replace the free-form failure sentence with a key=value layout that
surfaces the outer XDR result code, inner result code, op result
code, and an optional contract-level error extracted from Soroban
diagnostic events. Adds a contract_error field on the
"stellar transaction failed" warn log.

Old:
  Transaction failed on-chain. Provider status: FAILED.
  Specific XDR reason: TxFeeBumpInnerFailed.

New:
  Transaction failed on-chain. reason=TxFeeBumpInnerFailed
  inner=TxFailed op=Trapped contract_error=Contract(8)
  message="failing with contract error"

Verified against 24h of prod-mainnet traffic (~40k on-chain
failures, 99.5% Trapped) by decoding real diagnosticEventsXdr
through the new extractor. Includes 11 new unit tests including
a real prod XDR fixture.

Signed-off-by: Dylan Kilkenny <dylankilkenny95@gmail.com>
@dylankilkenny dylankilkenny requested a review from a team as a code owner May 6, 2026 17:23
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Caution

Review failed

Failed to post review comments

Walkthrough

The Stellar status handling module enriches transaction failure diagnostics by extracting contract-level errors from Soroban diagnostic events and building structured, multi-part failure reasons that replace simple provider-status messages. New helper functions format failure details and sanitize error messages.

Changes

Stellar Transaction Failure Diagnostics

Layer / File(s) Summary
Type/Import Expansion
src/domain/transaction/stellar/status.rs
Imports expanded to include ContractEventBody, DiagnosticEvent, InnerTransactionResultResult, OperationResult, OperationResultTr, ScVal, TransactionEnvelope, TransactionResultResult, and WriteXdr for diagnostic event parsing and XDR manipulation.
Failure Reason Formatting
src/domain/transaction/stellar/status.rs
New format_failure_reason(outer, inner, op, contract_error) helper builds structured failure strings from outer result code, inner result code, operation result code, and extracted contract error.
Contract Error Extraction
src/domain/transaction/stellar/status.rs
New extract_contract_error(events) function traverses Soroban diagnostic events and calls scan_scval() to derive human-readable contract errors from ScVal fields; includes sanitize_message() to clean error text.
Integration & Enrichment
src/domain/transaction/stellar/status.rs
Failure handling extracts contract error from provider_response.diagnostic_events, logs it, and passes it to format_failure_reason() to replace previous provider-status-based message. Transaction result XDR and fee data are stored when available. parse_and_validate_hash() method made public.
Tests & Expectations
src/domain/transaction/stellar/status.rs
Updated test expectations for failure reason format and added extensive tests for format_failure_reason() variants, contract error extraction, first-failing-operation detection, and message sanitization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🐰 A tale of errors, once opaque,
Now shine with Soroban's truth at stake,
Through diagnostic veils we peer,
Contract whispers crystal clear,
Stellar transactions, debugged by us hares, forsake the murk!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(stellar): Structure failed tx status_reason' directly and specifically describes the main change—restructuring the failure status reason field for Stellar transactions.
Description check ✅ Passed The description provides comprehensive context: a clear summary of the change with before/after examples, compatibility warnings, implementation details, and testing information.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 001-stellar-failure-detail

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 95.14170% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (2c785fd) to head (ae3c00f).

Files with missing lines Patch % Lines
src/domain/transaction/stellar/status.rs 95.14% 12 Missing ⚠️
Additional details and impacted files
Flag Coverage Δ
ai 0.00% <0.00%> (ø)
dev 90.32% <95.14%> (+0.01%) ⬆️
properties 0.01% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
+ Coverage   90.31%   90.32%   +0.01%     
==========================================
  Files         291      291              
  Lines      124258   124502     +244     
==========================================
+ Hits       112219   112453     +234     
- Misses      12039    12049      +10     
Files with missing lines Coverage Δ
src/domain/transaction/stellar/status.rs 95.65% <95.14%> (-0.07%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dylankilkenny dylankilkenny merged commit 4bfd68d into main May 7, 2026
28 checks passed
@dylankilkenny dylankilkenny deleted the 001-stellar-failure-detail branch May 7, 2026 16:53
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants